package me.tonywang.config;

import com.baomidou.mybatisplus.MybatisSqlSessionTemplate;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("me.tonywang.**.dao")
public class MybatisPlusConfig {

    /**
     * mybatis-plus分页插件<br>
     * 文档：http://mp.baomidou.com<br>
     */
    @Bean
    @ConfigurationProperties(prefix = "mybatis-plus.pagination-interceptor")
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor interceptor = new PaginationInterceptor();
//        interceptor.setDialectType(DBType.SQLSERVER.getDb());
        return interceptor;
    }

    @Bean
    MybatisSqlSessionTemplate mybatisSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
        return new MybatisSqlSessionTemplate(sqlSessionFactory);
    }

}
